import Vue from "vue";
import VueRouter from "vue-router";


//解决连续点击同个路由出bug------------------
const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}
//解决连续点击同个路由出bug------------------

Vue.use(VueRouter);
const routes = [
  {
    path: "/",
    redirect : '/box'
  },
  {
    path: "/reg",
    name: "reg",
    component: () => import("../views/Reg"),//省略了index.vue
    meta:{
   title:'注册页'
    }
  }, {
    path: "/login",
    name: "login",
    component: () => import("../views/Login"),//省略了index.vue
    meta:{
      title:'登入页'
       }
  },{
    path: "/box",
    name: "box",
    component: () => import("../views/Box"),//省略了index.vue
    meta:{
      title:'主页面'
    },
    children:[
      {
        path : 'users',
        component: () => import('../views/Users'),
        name: "users",
        meta : {
          title : '用户管理'
        }
      },{
        path : 'orders',
        component: () => import('../views/Orders'),
        name: "orders",
        meta : {
          title : '订单管理'
        }
      },{
        path : 'goods',
        component: () => import('../views/Goods'),
        name: "goods",
        meta : {
          title : '商品管理'
        }
      },{
        path : 'comments',
        component: () => import('../views/Comments'),
        name: "comments",
        meta : {
          title : '评论管理'
        }
      }
    ]
  }
   
];

const router = new VueRouter({
  routes
});

export default router;
